<template>
    <!-- <div class="details-container">
        <div class="iconfont icon-fanhui"></div>
        <div class="title">标题</div>
        <div class="describe">描述</div>
        <div class="info">
            <div class="tags">
                <div class="tag">关键词1</div>
                <div class="tag">关键词1</div>
                <div class="tag">关键词1</div>
            </div>
            <div class="other">
                <div class="teme">
                     <span>2222-02-22</span>
                     <span>丨</span>
                </div>
               <div class="see">
                   <div class="icon font icon-see2"></div>
                   <div>4500</div>
               </div>
            </div>
        </div>  
    </div> -->
      <div>
    <div class="topic">
      <div class="topicList" v-for="(temp,index) in value" :key="index" @click="routerLink(temp)">
        <div class="topicImg">
          <img :src="temp.poster | cover" class="cover-img">
        </div>
        <div class="topicTitle">{{temp.title}}</div>
        <div class="topicInfo">
          <div class="time">
            <span class="iconfont icon-shijian"></span>
            <span>{{temp.created_at  | parseTime('{y}-{m}-{d}') }}</span>
          </div>
          <div class="see">
            <span class="iconfont icon-chakan"></span>
            <span>{{temp.hit}}</span>
          </div>
          <div class="btn">
            <div class="iconfont icon-tuxing"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  filters: {
    cover(posters) {
      if (!posters) return "http://placehold.it/640x1280";
      return posters.split(",")[0];
    },
    parseTime(time, cFormat) {
      if (arguments.length === 0) {
        return null;
      }
      const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
      let date;
      if (typeof time === "object") {
        date = time;
      } else {
        if (typeof time === "string" && /^[0-9]+$/.test(time)) {
          time = parseInt(time);
        }
        if (typeof time === "number" && time.toString().length === 10) {
          time = time * 1000;
        }
        date = new Date(time);
      }
      const formatObj = {
        y: date.getFullYear(),
        m: date.getMonth() + 1,
        d: date.getDate(),
        h: date.getHours(),
        i: date.getMinutes(),
        s: date.getSeconds(),
        a: date.getDay()
      };
      const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
        let value = formatObj[key];
        // Note: getDay() returns 0 on Sunday
        if (key === "a") {
          return ["日", "一", "二", "三", "四", "五", "六"][value];
        }
        if (result.length > 0 && value < 10) {
          value = "0" + value;

        }
        return value || 0;
      });
      return time_str;
    }
  },
  props: {
    value: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  created() {
    console.log(this.value);
  },
  methods: {
    routerLink(name) {
     this.$router.push({name})
    }
  }
};
</script>


<style lang="less">
// .details-container{
//     width: 100%;
// }
.topic {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  color: #3d3d3d;
  font-size: 14px;
  // padding-top: 50px;
  .topicList {
    width: 358px;
    padding: 20px 0;
    margin: 0 15px;
    .topicImg {
      width: 358px;
      height: 252px;
      background: rgba(176, 176, 176, 1);
      overflow: hidden;
      transition: all 2s;
      :hover{
          transform: scale(1.1);
      }  
      img {
        width: 100%;
        
      }
    }
    .cover-img{
      transition: all 2s;
      :hover{
          transform: scale(1.1);
      }  
    }
    .topicTitle {
      color: #444;
      font-size: 18px;
      padding-top: 16px;
    }
    .topicDescribe {
      width: 358px;
      // border: 1px solid;
      padding-top: 10px;
      font-size: 14px;
    }
    .topicInfo {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 14px;
      .btn {
        padding: 2px 30px;
        border-radius: 5px;
        border: 1px solid;
        .iconfont {
          font-size: 21px;
        }
      }
    }
  }
}
</style>